package com.fr.chart.plot;

import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.util.Utils;

public class CustomAttr extends SeriesAttr
{
  private static final long serialVersionUID = 1257022581265772235L;
  public static final String XML_TAG = "CustomAttr";
  private int renderer = 1;
  private String axisPosition = "LEFT";

  public CustomAttr()
  {
  }

  public CustomAttr(int paramInt)
  {
    setRenderer(paramInt);
  }

  public void setRenderer(int paramInt)
  {
    this.renderer = paramInt;
  }

  public int getRenderer()
  {
    return this.renderer;
  }

  public void setAxisPosition(String paramString)
  {
    this.axisPosition = paramString;
  }

  public String getAxisPosition()
  {
    return this.axisPosition;
  }

  public void setRenderer(Plot paramPlot)
  {
    if (paramPlot instanceof LinePlot)
      setRenderer(2);
    else if (paramPlot instanceof AreaPlot)
      setRenderer(4);
    else
      setRenderer(1);
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("CustomAttr");
    super.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.startTAG("customattr").attr("renderer", this.renderer).attr("axisPosition", this.axisPosition).end();
    paramXMLPrintWriter.end();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if (str1.equals("customattr"))
      {
        String str2;
        if ((str2 = paramXMLableReader.getAttr("renderer")) != null)
          this.renderer = Utils.string2Number(str2).intValue();
        if ((str2 = paramXMLableReader.getAttr("axisPosition")) != null)
          this.axisPosition = str2;
      }
    }
  }

  public String getSeriesAttrType()
  {
    return "CustomAttr";
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = super.toJSONObject();
    localJSONObject.put("renderer", this.renderer);
    localJSONObject.put("axisPosition", this.axisPosition);
    return localJSONObject;
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    CustomAttr localCustomAttr = (CustomAttr)super.clone();
    return localCustomAttr;
  }
}